package randombeanmachine;

import junit.framework.TestCase;

import java.util.List;
import java.util.Map;

public class RandomBeanMachineTest extends TestCase {

    public void testGenericisedLists() {
        ObjectWithGenericList o = new RandomBeanMachine()
                .withOneEntryCollections()
                .create(ObjectWithGenericList.class);
        assertEquals(1, o.value.size());

    }

    public void testListOfPrimitives() {
        ObjectWithPrimitiveList thing = new RandomBeanMachine().withOneEntryCollections().create(ObjectWithPrimitiveList.class);
        assertEquals(1, thing.value.size());
        assertTrue(thing.value.get(0).length() > 0);
    }

    public void testGenericisedMaps() {
        ObjectWithGenericMap o = new RandomBeanMachine()
                .withOneEntryCollections()
                .create(ObjectWithGenericMap.class);
        assertEquals(1, o.value.keySet().size());
        assertEquals(1, o.value.values().size());

    }

    class ObjectWithGenericList {
        List<ObjectWithStringProperty> value;
    }

    class ObjectWithPrimitiveList {
        List<String> value;
    }

    class ObjectWithGenericMap {
        Map<ObjectWithStringProperty, ObjectWithStringProperty> value;
    }

    class ObjectWithStringProperty {
        String value;
    }

}
